/**
 * 中间件
 * 处理服务总耗时时间
 */
module.exports = async (ctx, next) => {
  const start = new Date();
  await next();
  const end = new Date();
  const duration = end - start;
  // ctx.set() 设置响应头
  ctx.set('X-Response-Time', duration + 'ms')
}